package com.yd.app.mapper;

import com.yd.app.mapper.provider.GStyleProvider;
import com.yd.domain.business.GStyle;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 产品样式Mapper
 * Created by sunxianhui on 2018/3/9.
 */
@Repository
public interface GStyleMapper {

    /**
     * 添加产品样式
     * @param gStyle
     */
    @Insert("insert into business_gStyle (id,typeName,ifUse,sort,pId) values (#{gStyle.id},#{gStyle.typeName},#{gStyle.ifUse},#{gStyle.sort},#{gStyle.pId})")
    int addGStyle(@Param("gStyle") GStyle gStyle);

    /**
     * 修改
     * @param gStyle
     */
    @Update("update business_gStyle set typeName=#{gStyle.typeName},ifUse=#{gStyle.ifUse},sort=#{gStyle.sort},pId=#{gStyle.pId},pId=#{gStyle.pId} where id=#{gStyle.id}")
    int updateGStyle(@Param("gStyle") GStyle gStyle);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from business_gStyle where id=#{id}")
    int deleteGStyleById(@Param("id") String id);

    /**
     * @return
     */
    @Select("select * from business_gStyle order by sort")
    List<GStyle> getGStyleList();

    /**
     * 根据条件查询数量
     * @param id
     * @return
     */
    @SelectProvider(method = "searchGStyleCount", type = GStyleProvider.class)
    int getGStyleCount(@Param("id") String id);

}
